<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:ic="http://ivyteam.ch/jsf/component"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:pm="http://primefaces.org/mobile">
<p:dialog id="editingExamDialog" modal="true" header="#{data.examDialogTitle}"
	widgetVar="editingExamDialog" style="width:768px;">
	<h:form id="examInfo">
		<p:panelGrid columns="3" style="width:100%">
			<p:outputLabel
				value="#{ivy.cms.co('/axonactive/vision/training/lblTitle')}"></p:outputLabel>
			<p:inputText id="examTitle" value="#{data.editedExam.title}"
				style="width:100%" required="true"
				requiredMessage="#{ivy.cms.co('/axonactive/vision/training/lblRequired')}"></p:inputText>
			<p:message for="examTitle"></p:message>
			<p:outputLabel
				value="#{ivy.cms.co('/axonactive/vision/training/lblTime')}"></p:outputLabel>
			<pe:inputNumber id="examTime" value="#{data.editedExam.time}"
				required="true"
				requiredMessage="#{ivy.cms.co('/axonactive/vision/training/lblRequired')}"></pe:inputNumber>
			<p:message for="examTime"></p:message>
			<p:outputLabel value=""></p:outputLabel>
			<p:selectBooleanCheckbox value="#{data.editedExam.available}"
				itemLabel="#{ivy.cms.co('/axonactive/vision/training/lblReadyForTest')}" />
		</p:panelGrid>
		<p:outputPanel>
			<p:outputPanel style="float:left;">
				<p:outputLabel
					value="#{ivy.cms.co('/axonactive/vision/training/lblQuestionList')}"></p:outputLabel>
			</p:outputPanel>
			<p:outputPanel style="float:right;">
				<p:commandButton
					value="#{ivy.cms.co('/axonactive/vision/training/lblAdd')}"
					actionListener="#{logic.addQuestion}"
					update=":#{p:component('questionInfo')}"
					oncomplete="editingQuesDialog.show()"></p:commandButton>
			</p:outputPanel>
		</p:outputPanel>
		<p:outputPanel style="clear:both; margin-bottom:10px;">
			<p:dataTable var="question" value="#{data.questionDatatableDTO}"
				rows="10" rowKey="#{question.index}" lazy="true" first="0"
				selection="#{data.questionDatatableDTO.seletedQuestion}"
				selectionMode="single"
				sortBy="index"
				widgetVar="questionDatatable">
				<p:column
					headerText="#{ivy.cms.co('/axonactive/vision/training/tableQuestion/headerNo')}"
					sortBy="index">
					<h:outputText value="#{question.index + 1}"></h:outputText>
				</p:column>
				<p:column
					headerText="#{ivy.cms.co('/axonactive/vision/training/tableQuestion/headerContent')}"
					sortBy="question">
					<h:outputText value="#{question.question.question}"></h:outputText>
				</p:column>
				<p:column
					headerText="#{ivy.cms.co('/axonactive/vision/training/tableQuestion/headerType')}">
					<h:outputText value="#{question.question.type}"></h:outputText>
				</p:column>
				<p:column
					headerText="#{ivy.cms.co('/axonactive/vision/training/tableQuestion/headerAnswer')}">
					<h:outputText value="#{question.question.answer}"></h:outputText>
				</p:column>
				<p:column
					headerText="#{ivy.cms.co('/axonactive/vision/training/tableQuestion/headerAction')}">
					<h:outputLabel style="display:none" styleClass="row_#{question.index}"></h:outputLabel>
					<p:commandLink
						onstart="seletedRow(#{question.index})"
						value="#{ivy.cms.co('/axonactive/vision/training/lblEdit')}" 
						actionListener="#{logic.editQuestion}"
						update=":#{p:component('editingQuesDialog')}"
						oncomplete="editingQuesDialog.show()"></p:commandLink>
					<p:outputLabel value="/"></p:outputLabel>
					<p:commandLink
						onstart="seletedRow(#{question.index})"
						value="#{ivy.cms.co('/axonactive/vision/training/lblDelete')}"
						update=":#{p:component('examInfo')} "
						actionListener="#{logic.removeQuestion}"></p:commandLink>
				</p:column>
			</p:dataTable>
		</p:outputPanel>
		<p:outputPanel>
			<p:outputPanel style="float:right;">
				<p:commandButton
					value="#{ivy.cms.co('/axonactive/vision/training/lblSave')}"
					actionListener="#{logic.saveExamDialog}"
					update=":#{p:component('Exam')}, :#{p:component('listExam')}, :#{p:component('examInfo')}"></p:commandButton>
				<p:commandButton
					value="#{ivy.cms.co('/axonactive/vision/training/lblCancel')}"
					onclick="editingExamDialog.hide()" immediate="true" process="@this"
					actionListener="#{logic.resetExam}"
					style="margin-left:10px;"></p:commandButton>
			</p:outputPanel>
		</p:outputPanel>
	</h:form>
</p:dialog>
</html>